package com.sisyphus.mock.configs;

import android.content.Context;

import com.yanzhenjie.andserver.annotation.Config;
import com.yanzhenjie.andserver.framework.config.Multipart;
import com.yanzhenjie.andserver.framework.config.WebConfig;
import com.yanzhenjie.andserver.framework.website.AssetsWebsite;
import com.yanzhenjie.andserver.framework.website.StorageWebsite;

import java.io.File;

@Config
public class GlobalConfig implements WebConfig {

    @Override
    public void onConfig(Context context, Delegate delegate) {
        // 资源
        delegate.addWebsite(new AssetsWebsite(context, "/"));
        delegate.addWebsite(new StorageWebsite("/_mock_image_file"));

        // 访问
        delegate.setMultipart(
                Multipart.newBuilder()
//            .allFileMaxSize(1024 * 1024 * 20) // 20M
//            .fileMaxSize(1024 * 1024 * 5) // 5M
//            .maxInMemorySize(1024 * 10) // 1024 * 10 bytes
                        .uploadTempDir(new File(context.getCacheDir(), "_server_upload_cache_"))
                        .build()
        );
    }

}
